package com.twu.biblioteca;

import java.util.HashMap;
import java.util.Scanner;

public class BibliotecaApp {

    public static void main(String[] args) throws Exception{



        Scanner scanner = new Scanner(System.in);
        int option;

        Library library = getLibrary();

        library.getGreetingMessage();

        while(true){
            library.getMenu();

            option = Integer.parseInt(scanner.nextLine());

            library.getCommands().get(option).invoke(library);
        }


    }

    private static Library getLibrary() throws Exception{
        HashMap<Integer, Movie> mapOfMovies = new HashMap<Integer, Movie>();
        mapOfMovies.put(1, new Movie(1, "500 Days of Summer", 2009, "Marc Webb", 8.0f, 3));
        mapOfMovies.put(2, new Movie(2, "Eternal Sunshine of the Spotless Mind", 2004, "Michel Gondry", 8.4f, 1));
        mapOfMovies.put(3, new Movie(3, "Sympathy for Lady Vengeance", 2005, "Park Chan-wook", 7.7f, 0));
        mapOfMovies.put(4, new Movie(4, "Oculus", 2014, "Mike Flanagan", 7.0f, 1));

        HashMap<Integer, Book> mapOfBooks = new HashMap<Integer, Book>();
        mapOfBooks.put(1, new Book(1, "Head First C#", 3));
        mapOfBooks.put(2, new Book(2, "Head First PMP", 3));

        HashMap<String, User> mapOfUsers = new HashMap<String, User>();
        mapOfUsers.put("123-1234", new User("123-1234", "Renjith", "123456", "test@test.com", "1234567890"));
        mapOfUsers.put("123-1235", new User("123-1235", "Sumit", "123789", "test@test.com", "1234567890"));
        mapOfUsers.put("123-1236", new User("123-1236", "Manu", "123123", "test@test.com", "1234567890"));

        return new Library(mapOfMovies, mapOfBooks, mapOfUsers);
    }
}
